﻿#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    initUI();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::initUI()
{
    ui->comboBox_educ->clear();
    QStringList list;
    list<<"幼儿园"<<"小学"<<"初中"<<"高中"<<"大学"<<"研究生"<<"博士"<<"博士后";
    ui->comboBox_educ->addItems(list);
    ui->comboBox_educ->setEditable(true);



    QMap<QString,QString>citys;
    citys.insert("北京","010");
    citys.insert("上海","020");
    citys.insert("江苏","030");
    citys.insert("四川","040");

    for(auto it=citys.begin();it!=citys.end();it++)
    {
        ui->comboBox_city->addItem(it.key(),it.value());
    }

    QIcon icon1;
    icon1.addFile(":/mmexport1741683232826.jpg");
    ui->comboBox_hobby->addItem(icon1,"内女");
    QIcon icon2;
    icon2.addFile(":/mmexport1741683579018.jpg");
    ui->comboBox_hobby->addItem(icon2,"人才");

}

void MainWindow::onChange()
{
    QString xueli=ui->comboBox_educ->currentText();
    QString city=ui->comboBox_city->currentText();
    QString love=ui->comboBox_hobby->currentText();
    QString number=ui->comboBox_city->currentData().toString();

    QString ret="学历: "+xueli+" 爱好: "+love+ " 城市: "+city+" 区号: "+number;
    ui->label_4->setText(ret);

}


void MainWindow::on_comboBox_educ_currentIndexChanged(int index)
{
    onChange();
}

void MainWindow::on_comboBox_city_currentIndexChanged(int index)
{
    onChange();
}

void MainWindow::on_comboBox_hobby_currentTextChanged(const QString &arg1)
{
    onChange();
}
